/**
 * 检测设备类型
 */
export const detectDevice=():'tablet' | 'desktop' | 'phone'=> {
  const userAgent = navigator.userAgent;
  const platform = navigator.platform;
  const screenWidth = window.screen.width;
  const screenHeight = window.screen.height;

  // 判断是否为移动设备
  const mobileKeywords = /iPhone|iPad|iPod|Android/i;
  const isMobile = mobileKeywords.test(userAgent);

  // 判断是否为平板设备
  const tabletKeywords = /iPad|Tablet|PlayBook/i;
  const isTablet = tabletKeywords.test(userAgent) || (screenWidth >= 768 && screenHeight >= 1024);

  // 判断是否为 PC 设备
  const isPC = !isMobile && !isTablet;

  if (isMobile) {
    return 'phone';
  } else if (isTablet) {
    return 'tablet';
  } else if (isPC) {
    return 'desktop';
  }
  return 'desktop';
}


/**
 * 是否为手机
 */
export const isPhone=():boolean=>{
  return detectDevice() === 'phone';
}
